package com.sbs.gaoxinqutoilet.adapter;


import android.text.TextUtils;
import android.view.View;

import androidx.annotation.LayoutRes;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sbs.gaoxinqutoilet.R;
import com.sbs.gaoxinqutoilet.entity.ReBuildItemEntity;
import com.zhy.autolayout.utils.AutoUtils;

import java.util.List;

/**
 * Created by 聪明一只哈 on 2018/5/30.
 * Time: 2018/5/30  17:37
 */

public class ToiletRebuildRvAdapter extends BaseQuickAdapter<ReBuildItemEntity.DataBean, ToiletRebuildRvAdapter.BuyApplyViewHolder> {


    public ToiletRebuildRvAdapter(@LayoutRes int layoutResId, @Nullable List<ReBuildItemEntity.DataBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BuyApplyViewHolder helper, ReBuildItemEntity.DataBean item) {

        helper.setText(R.id.item_rebuild_tv_name,item.getHuming());
        helper.setText(R.id.item_rebuild_buildtype,item.getGaizao_type_n());
        helper.setText(R.id.item_rebuild_address,item.getArea_name());

        //item.getGaizao_type_n_cj();
        //这里根据改造类型是否有值来判断是否显示  已重建和未重建状态
        String gaizao_type_cj = item.getGaizao_type_cj();

        if (TextUtils.isEmpty(gaizao_type_cj)||gaizao_type_cj==null){
            helper.setText(R.id.item_rebuild_statedesc,"未重建");
            helper.getView(R.id.item_rebuild_image).setBackgroundResource(R.drawable.unrebuild);
        }else{
            helper.setText(R.id.item_rebuild_statedesc,"已重建");
            helper.getView(R.id.item_rebuild_image).setBackgroundResource(R.drawable.alrebuild);
        }


//----------adapter条目点击-----------------------------------
//        helper.addOnClickListener(R.id.buy_apply_ll).addOnClickListener(R.id.buy_state_delete)
//                .addOnClickListener(R.id.buy_state_upload);

    }

    public class BuyApplyViewHolder extends BaseViewHolder {

        public BuyApplyViewHolder(View view) {
            super(view);
            AutoUtils.auto(view);
        }
    }
}
